//
//  UIButton+Extension.m
//  WHYWeibo-OC
//
//  Created by 王洪运 on 15/11/22.
//  Copyright © 2015年 王洪运. All rights reserved.
//

#import "UIButton+Extension.h"

@implementation UIButton (Extension)
+(instancetype)buttonWithImageName:(NSString *)imageName andBackIamgeName:(NSString *)backImageName {
    UIButton * button = [self new];
    
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]] forState:UIControlStateHighlighted];
    
    [button setBackgroundImage:[UIImage imageNamed:backImageName] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",backImageName]] forState:UIControlStateHighlighted];
    
    return button;
}

+(instancetype)buttonWithTitle:(NSString *)title titleColor:(UIColor *)titleColor fontSize:(CGFloat)fontSize backImageName:(NSString *)backImageName {
    UIButton *button = [self new];
    
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitleColor:titleColor forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:fontSize];
    [button setBackgroundImage:[UIImage imageNamed:backImageName] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",backImageName]] forState:UIControlStateHighlighted];
    
    return button;
}

@end
